@using Abc.Core;
@using Abc.Application;
@using Abc.Core.Entities;
@model Abc.Application.UserOut;
@{
    ViewData["Title"] = "UserInfo";
}

<section class="panel panel-padding">
    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">

        <form class="layui-form" action="">
            <input type="hidden" asp-for="Id" />
            <div class="layui-form-item">
                <label class="layui-form-label">账户类型</label>
                <div class="layui-input-block">
                    @*<input asp-for="UserType" lay-verify="UserType" autocomplete="off" placeholder="请输入账户类型" class="layui-input">*@
                    <select asp-for="UserType" lay-verify="required" lay-reqtext="请选择账户类型">
                        @foreach (int val in Enum.GetValues(typeof(UserType)))
                        {
                            <option value="@(val)">@(((UserType)val).ToString())</option>
                        }
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-block">
                    <input asp-for="Account" lay-verify="required|account" lay-reqText="用户名不能为空！" autocomplete="off" placeholder="请输入用户名" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input name="Pwd" lay-verify="pwd" autocomplete="off" placeholder="请输入密码" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">是否启用</label>
                <div class="layui-input-block">
                    @*<input type="checkbox" asp-for="IsEnable" lay-skin="primary" title="" checked="">
                        <input type="checkbox" name="like[read]" title="阅读" checked="">*@
                    <input type="checkbox" asp-for="IsEnable" lay-skin="switch" lay-text="开|关">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">是否测试</label>
                <div class="layui-input-block">
                    @*<input type="checkbox" asp-for="IsTest" lay-skin="primary" title="" checked="">
                        <input type="checkbox" name="like[read]" title="阅读" checked="">*@
                    <input type="checkbox" asp-for="IsTest" lay-skin="switch" lay-text="开|关">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">昵称</label>
                <div class="layui-input-block">
                    <input asp-for="Nick" lay-verify="nick" autocomplete="off" placeholder="请输入昵称" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-block">
                    <input asp-for="Email" autocomplete="off" placeholder="请输入邮箱" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">省份</label>
                <div class="layui-input-block">
                    <input asp-for="Province" lay-verify="province" autocomplete="off" placeholder="请输入省份" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">城市</label>
                <div class="layui-input-block">
                    <input asp-for="City" lay-verify="city" autocomplete="off" placeholder="请输入城市" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">镇</label>
                <div class="layui-input-block">
                    <input asp-for="Town" lay-verify="town" autocomplete="off" placeholder="请输入镇" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">详细地址</label>
                <div class="layui-input-block">
                    <input asp-for="Address" lay-verify="address" autocomplete="off" placeholder="请输入详细地址" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">联系电话</label>
                <div class="layui-input-block">
                    <input asp-for="Phone" autocomplete="off" placeholder="请输入联系电话" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">办公电话</label>
                <div class="layui-input-block">
                    <input asp-for="Tel" lay-verify="tel" autocomplete="off" placeholder="请输入办公电话" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <textarea asp-for="Remark" lay-verify="Remark" autocomplete="off" placeholder="请输入备注" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item" pane="">
                <label class="layui-form-label" style="width: 120px;">管理角色设置</label>
                <div class="layui-input-block">
                    @{
                        List<RoleOut> Roles = (List<RoleOut>)@ViewBag.Roles;
                    }
                    @foreach (RoleOut item in @Roles)
                    {
                        //if (Roles.Any(o => o.RoleId == item.Id))
                        @if (Model.Roles != null && Model.Roles.Any(o => o.Id == item.Id))
                        {
                            <input type="checkbox" name="role" lay-skin="primary" title="@item.Name" value="@item.Id" checked="">
                        }
                        else
                        {
                            <input type="checkbox" name="role" lay-skin="primary" title="@item.Name" value="@item.Id">
                        }

                    }
                    @*<input type="checkbox" name="like1[write]" lay-skin="primary" title="写作" checked="">
                        <input type="checkbox" name="like1[read]" lay-skin="primary" title="阅读">
                        <input type="checkbox" name="like1[game]" lay-skin="primary" title="游戏" disabled="">*@
                </div>
            </div>
            @*
                <textarea placeholder="请输入内容" class="layui-textarea"></textarea>
                <input type="radio" name="sex" value="男" title="男" checked="">
                <input type="radio" name="sex" value="女" title="女">
                <input type="radio" name="sex" value="禁" title="禁用" disabled="">
            *@
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <div class="layui-btn" lay-submit lay-filter="submit">提交数据</div>
                    <div class="layui-btn layui-btn-danger closewindow">关闭窗口</div>
                    <div class="layui-btn layui-btn-danger refreshwindow">重新加载</div>
                </div>
            </div>
        </form>
    </div>
</section>

@*<script src="~/lib/ckeditor4/ckeditor.js"></script>*@
@section Scripts{
    <script>
    layui.define(['element', 'upload', 'jquery', 'form', 'table', 'laydate'], function () {
        var $ = layui.jquery
            , upload = layui.upload,
            form = layui.form,
            table = layui.table,
            laydate = layui.laydate,
            element = layui.element;

        //Info 初始化
        app.infoInit();
        //提交
        form.on('submit(submit)', function (obj) {
            //obj.field.IsEnable=$('#IsEnable').is(':checked');
            //obj.field.Remark = Remark.getContent();
            var roleids = "";
            $('input[name="role"]:checked').each(function () {
                var value = $(this).val();
                roleids += "," + value;
            });

            obj.field.RoleIds = roleids;

            app.post({url:'@(Url.Action("Edit"))',data:obj.field});

            return false;
        });

        //生成时间监听
        //有时间字段才有下面的代码
          // var arrDateEle = 'LastLoginTime,CreationTime,UpdateTime,DeletedTime';
           //app.initDate('LastLoginTime,CreationTime,UpdateTime,DeletedTime');
    });
    </script>
}